<?php

class Third_Loader
{
    static $_mapFiles = array(
        'jsmin'  => '/jsmin/jsmin.php',
        'cssmin' => '/cssmin/cssmin.php',
        'snoopy' => '/snoopy/Snoopy.class.php',
    );

    static $_loaded = array();

    static function getClass($name)
    {
        if (!isset(self::$_mapFiles[$name]))
            throw new NullPointerException();
        $classFile = __DIR__ . self::$_mapFiles[$name];
        if (is_file($classFile)) {
            self::$_loaded[$name] = TRUE;
            require_once $classFile;
        }
        else
            throw new FileNotFoundException();
    }

    static function auto($classname)
    {
        $flag = (class_exists($classname, FALSE) || interface_exists($classname, FALSE));
        if (!$flag && !isset(self::$_loaded[$classname]))
        {
            Third_Loader::getClass($classname);
        }
    }

    static function register()
    {
        spl_autoload_register(array(__CLASS__, 'auto'));
    }

    static function unregister()
    {
        spl_autoload_unregister(array(__CLASS__, 'auto'));
    }
}

?>